<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  <html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<title>File Source for html.php</title>
	<link rel="stylesheet" type="text/css" href="../media/style.css">
	<meta http-equiv='Content-Type' content='text/html; charset=iso-8859-1'/>
	<script src="media/a.js"></script>
</head>
<body>

<table border="0" cellspacing="0" cellpadding="0" height="48" width="100%">
  <tr>
	<td class="header-top-left"><img src="../media/logo.png" border="0" alt="phpDocumentor " /></td>
    <td class="header-top-right">Examples<br /><div class="header-top-right-subpackage"></div></td>
  </tr>
  <tr><td colspan="2" class="header-line"><img src="../media/empty.png" width="1" height="1" border="0" alt=""  /></td></tr>
  <tr>
    <td colspan="2" class="header-menu">
      
                                      
                                    		[ <a href="../classtrees_Examples.html" class="menu">class tree: Examples</a> ]
		[ <a href="../elementindex_Examples.html" class="menu">index: Examples</a> ]
            [ <a href="../elementindex.html" class="menu">all elements</a> ]
    </td>
  </tr>
  <tr><td colspan="2" class="header-line"><img src="../media/empty.png" width="1" height="1" border="0" alt=""  /></td></tr>
</table>

<table width="100%" border="0" cellpadding="0" cellspacing="0">
  <tr valign="top">
    <td width="195" class="menu">
		<div class="package-title">Examples</div>
  <div class="package">
	<div id="todolist">
			<p><a href="../todolist.html">Todo List</a></p>
	</div>
	</div>
      <b>Packages:</b><br />
  <div class="package">
              <a href="../li_QueryPath.html">QueryPath</a><br />
              <a href="../li_Examples.html">Examples</a><br />
              <a href="../li_Tests.html">Tests</a><br />
      	</div>
      <br />
                        <br />
                      </td>
    <td>
      <table cellpadding="10" cellspacing="0" width="100%" border="0"><tr><td valign="top">

<h1 align="center">Source for file html.php</h1>
<p>Documentation is available at <a href="../Examples/_examples---html.php.html">html.php</a></p>
<div class="src-code"><span class="php">
<ol><li><div class="src-line"><a name="a1"></a><span class="src-php">&lt;?php</span></div></li>
<li><div class="src-line"><a name="a2"></a><span class="src-doc">/**</span></div></li>
<li><div class="src-line"><a name="a3"></a><span class="src-doc">&nbsp;*&nbsp;Using&nbsp;QueryPath.</span></div></li>
<li><div class="src-line"><a name="a4"></a><span class="src-doc">&nbsp;*</span></div></li>
<li><div class="src-line"><a name="a5"></a><span class="src-doc">&nbsp;*&nbsp;This&nbsp;file&nbsp;contains&nbsp;an&nbsp;example&nbsp;of&nbsp;how&nbsp;QueryPath&nbsp;can&nbsp;be&nbsp;used</span></div></li>
<li><div class="src-line"><a name="a6"></a><span class="src-doc">&nbsp;*&nbsp;to&nbsp;generate&nbsp;web&nbsp;pages.&nbsp;Part&nbsp;of&nbsp;the&nbsp;design&nbsp;of&nbsp;this&nbsp;example&nbsp;is&nbsp;to&nbsp;exhibit&nbsp;many</span></div></li>
<li><div class="src-line"><a name="a7"></a><span class="src-doc">&nbsp;*&nbsp;different&nbsp;QueryPath&nbsp;functions&nbsp;in&nbsp;one&nbsp;long&nbsp;chain.&nbsp;All&nbsp;of&nbsp;the&nbsp;methods&nbsp;shown</span></div></li>
<li><div class="src-line"><a name="a8"></a><span class="src-doc">&nbsp;*&nbsp;here&nbsp;are&nbsp;fully&nbsp;documented&nbsp;in&nbsp;</span><span class="src-doc-inlinetag">{@link&nbsp;QueryPath}</span><span class="src-doc">.</span></div></li>
<li><div class="src-line"><a name="a9"></a><span class="src-doc">&nbsp;*</span></div></li>
<li><div class="src-line"><a name="a10"></a><span class="src-doc">&nbsp;*&nbsp;The&nbsp;method&nbsp;used&nbsp;in&nbsp;this&nbsp;example&nbsp;is&nbsp;a&nbsp;typical&nbsp;example&nbsp;of&nbsp;how&nbsp;QueryPath&nbsp;can</span></div></li>
<li><div class="src-line"><a name="a11"></a><span class="src-doc">&nbsp;*&nbsp;gradually&nbsp;build&nbsp;up&nbsp;content.&nbsp;Other&nbsp;methods&nbsp;include&nbsp;using&nbsp;</span><span class="src-doc-inlinetag">{@link&nbsp;QPTPL}</span><span class="src-doc">&nbsp;for</span></div></li>
<li><div class="src-line"><a name="a12"></a><span class="src-doc">&nbsp;*&nbsp;templates,&nbsp;injecting&nbsp;database&nbsp;information&nbsp;with&nbsp;</span><span class="src-doc-inlinetag">{@link&nbsp;QPDB}</span><span class="src-doc">,&nbsp;and&nbsp;merging</span></div></li>
<li><div class="src-line"><a name="a13"></a><span class="src-doc">&nbsp;*&nbsp;data&nbsp;from&nbsp;one&nbsp;QueryPath&nbsp;to&nbsp;another.</span></div></li>
<li><div class="src-line"><a name="a14"></a><span class="src-doc">&nbsp;*</span></div></li>
<li><div class="src-line"><a name="a15"></a><span class="src-doc">&nbsp;*&nbsp;</span><span class="src-doc-coretag">@package</span><span class="src-doc">&nbsp;Examples</span></div></li>
<li><div class="src-line"><a name="a16"></a><span class="src-doc">&nbsp;*&nbsp;</span><span class="src-doc-coretag">@author</span><span class="src-doc">&nbsp;M&nbsp;Butcher&nbsp;&lt;matt@aleph-null.tv&gt;</span></div></li>
<li><div class="src-line"><a name="a17"></a><span class="src-doc">&nbsp;*&nbsp;</span><span class="src-doc-coretag">@license</span><span class="src-doc">&nbsp;LGPL&nbsp;The&nbsp;GNU&nbsp;Lesser&nbsp;GPL&nbsp;(LGPL)&nbsp;or&nbsp;an&nbsp;MIT-like&nbsp;license.</span></div></li>
<li><div class="src-line"><a name="a18"></a><span class="src-doc">&nbsp;*/</span></div></li>
<li><div class="src-line"><a name="a19"></a>&nbsp;</div></li>
<li><div class="src-line"><a name="a20"></a><span class="src-inc">require_once&nbsp;</span><span class="src-str">'src/QueryPath/QueryPath.php'</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a21"></a>&nbsp;</div></li>
<li><div class="src-line"><a name="a22"></a><span class="src-comm">//&nbsp;Begin&nbsp;with&nbsp;an&nbsp;HTML&nbsp;stub&nbsp;document&nbsp;(XHTML,&nbsp;actually),&nbsp;and&nbsp;navigate&nbsp;to&nbsp;the&nbsp;title.</span></div></li>
<li><div class="src-line"><a name="a23"></a><a href="../QueryPath/_src---QueryPath---QueryPath.php.html#functionqp">qp</a><span class="src-sym">(</span><span class="src-id"><a href="../QueryPath/QueryPath.html">QueryPath</a></span><span class="src-sym">::</span><span class="src-id">HTML_STUB</span><span class="src-sym">,&nbsp;</span><span class="src-str">'title'</span><span class="src-sym">)</span></div></li>
<li><div class="src-line"><a name="a24"></a>&nbsp;&nbsp;<span class="src-comm">//&nbsp;Add&nbsp;some&nbsp;text&nbsp;to&nbsp;the&nbsp;title</span></div></li>
<li><div class="src-line"><a name="a25"></a>&nbsp;&nbsp;<span class="src-sym">-&gt;</span><span class="src-id">text</span><span class="src-sym">(</span><span class="src-str">'Example&nbsp;of&nbsp;QueryPath.'</span><span class="src-sym">)</span></div></li>
<li><div class="src-line"><a name="a26"></a>&nbsp;&nbsp;<span class="src-comm">//&nbsp;Now&nbsp;look&nbsp;for&nbsp;the&nbsp;&lt;body&gt;&nbsp;element</span></div></li>
<li><div class="src-line"><a name="a27"></a>&nbsp;&nbsp;<span class="src-sym">-&gt;</span><span class="src-id">find</span><span class="src-sym">(</span><span class="src-str">':root&nbsp;body'</span><span class="src-sym">)</span></div></li>
<li><div class="src-line"><a name="a28"></a>&nbsp;&nbsp;<span class="src-comm">//&nbsp;Inside&nbsp;the&nbsp;body,&nbsp;add&nbsp;a&nbsp;title&nbsp;and&nbsp;paragraph.</span></div></li>
<li><div class="src-line"><a name="a29"></a>&nbsp;&nbsp;<span class="src-sym">-&gt;</span><span class="src-id">append</span><span class="src-sym">(</span><span class="src-str">'&lt;h1&gt;This&nbsp;is&nbsp;a&nbsp;test&nbsp;page&lt;/h1&gt;&lt;p&gt;Test&nbsp;text&lt;/p&gt;'</span><span class="src-sym">)</span></div></li>
<li><div class="src-line"><a name="a30"></a>&nbsp;&nbsp;<span class="src-comm">//&nbsp;Now&nbsp;we&nbsp;select&nbsp;the&nbsp;paragraph&nbsp;we&nbsp;just&nbsp;created&nbsp;inside&nbsp;the&nbsp;body</span></div></li>
<li><div class="src-line"><a name="a31"></a>&nbsp;&nbsp;<span class="src-sym">-&gt;</span><span class="src-id">children</span><span class="src-sym">(</span><span class="src-str">'p'</span><span class="src-sym">)</span></div></li>
<li><div class="src-line"><a name="a32"></a>&nbsp;&nbsp;<span class="src-comm">//&nbsp;Add&nbsp;a&nbsp;'class=&quot;some-class&quot;'&nbsp;attribute&nbsp;to&nbsp;the&nbsp;paragraph</span></div></li>
<li><div class="src-line"><a name="a33"></a>&nbsp;&nbsp;<span class="src-sym">-&gt;</span><span class="src-id">attr</span><span class="src-sym">(</span><span class="src-str">'class'</span><span class="src-sym">,&nbsp;</span><span class="src-str">'some-class'</span><span class="src-sym">)</span></div></li>
<li><div class="src-line"><a name="a34"></a>&nbsp;&nbsp;<span class="src-comm">//&nbsp;And&nbsp;add&nbsp;a&nbsp;style&nbsp;attribute,&nbsp;too,&nbsp;setting&nbsp;the&nbsp;background&nbsp;color.</span></div></li>
<li><div class="src-line"><a name="a35"></a>&nbsp;&nbsp;<span class="src-sym">-&gt;</span><span class="src-id">css</span><span class="src-sym">(</span><span class="src-str">'background-color'</span><span class="src-sym">,&nbsp;</span><span class="src-str">'#eee'</span><span class="src-sym">)</span></div></li>
<li><div class="src-line"><a name="a36"></a>&nbsp;&nbsp;<span class="src-comm">//&nbsp;Now&nbsp;go&nbsp;back&nbsp;to&nbsp;the&nbsp;paragraph&nbsp;again</span></div></li>
<li><div class="src-line"><a name="a37"></a>&nbsp;&nbsp;<span class="src-sym">-&gt;</span><span class="src-id">parent</span><span class="src-sym">(</span><span class="src-sym">)</span></div></li>
<li><div class="src-line"><a name="a38"></a>&nbsp;&nbsp;<span class="src-comm">//&nbsp;Before&nbsp;the&nbsp;paragraph&nbsp;and&nbsp;the&nbsp;title,&nbsp;add&nbsp;an&nbsp;empty&nbsp;table.</span></div></li>
<li><div class="src-line"><a name="a39"></a>&nbsp;&nbsp;<span class="src-sym">-&gt;</span><span class="src-id">prepend</span><span class="src-sym">(</span><span class="src-str">'&lt;table&nbsp;id=&quot;my-table&quot;&gt;&lt;/table&gt;'</span><span class="src-sym">)</span></div></li>
<li><div class="src-line"><a name="a40"></a>&nbsp;&nbsp;<span class="src-comm">//&nbsp;Now&nbsp;let's&nbsp;go&nbsp;to&nbsp;the&nbsp;table...</span></div></li>
<li><div class="src-line"><a name="a41"></a>&nbsp;&nbsp;<span class="src-sym">-&gt;</span><span class="src-id">find</span><span class="src-sym">(</span><span class="src-str">'#my-table'</span><span class="src-sym">)</span></div></li>
<li><div class="src-line"><a name="a42"></a>&nbsp;&nbsp;<span class="src-comm">//&nbsp;Add&nbsp;a&nbsp;couple&nbsp;of&nbsp;empty&nbsp;rows</span></div></li>
<li><div class="src-line"><a name="a43"></a>&nbsp;&nbsp;<span class="src-sym">-&gt;</span><span class="src-id">append</span><span class="src-sym">(</span><span class="src-str">'&lt;tr&gt;&lt;/tr&gt;&lt;tr&gt;&lt;/tr&gt;'</span><span class="src-sym">)</span></div></li>
<li><div class="src-line"><a name="a44"></a>&nbsp;&nbsp;<span class="src-comm">//&nbsp;select&nbsp;the&nbsp;rows&nbsp;(both&nbsp;at&nbsp;once)</span></div></li>
<li><div class="src-line"><a name="a45"></a>&nbsp;&nbsp;<span class="src-sym">-&gt;</span><span class="src-id">children</span><span class="src-sym">(</span><span class="src-sym">)</span></div></li>
<li><div class="src-line"><a name="a46"></a>&nbsp;&nbsp;<span class="src-comm">//&nbsp;Add&nbsp;a&nbsp;CSS&nbsp;class&nbsp;to&nbsp;both&nbsp;rows</span></div></li>
<li><div class="src-line"><a name="a47"></a>&nbsp;&nbsp;<span class="src-sym">-&gt;</span><span class="src-id">addClass</span><span class="src-sym">(</span><span class="src-str">'table-row'</span><span class="src-sym">)</span></div></li>
<li><div class="src-line"><a name="a48"></a>&nbsp;&nbsp;<span class="src-comm">//&nbsp;Now&nbsp;just&nbsp;get&nbsp;the&nbsp;first&nbsp;row&nbsp;(at&nbsp;position&nbsp;0)</span></div></li>
<li><div class="src-line"><a name="a49"></a>&nbsp;&nbsp;<span class="src-sym">-&gt;</span><span class="src-id">eq</span><span class="src-sym">(</span><span class="src-num">0</span><span class="src-sym">)</span></div></li>
<li><div class="src-line"><a name="a50"></a>&nbsp;&nbsp;<span class="src-comm">//&nbsp;Add&nbsp;a&nbsp;table&nbsp;header&nbsp;in&nbsp;the&nbsp;first&nbsp;row</span></div></li>
<li><div class="src-line"><a name="a51"></a>&nbsp;&nbsp;<span class="src-sym">-&gt;</span><span class="src-id">append</span><span class="src-sym">(</span><span class="src-str">'&lt;th&gt;This&nbsp;is&nbsp;the&nbsp;header&lt;/th&gt;'</span><span class="src-sym">)</span></div></li>
<li><div class="src-line"><a name="a52"></a>&nbsp;&nbsp;<span class="src-comm">//&nbsp;Now&nbsp;go&nbsp;to&nbsp;the&nbsp;next&nbsp;row</span></div></li>
<li><div class="src-line"><a name="a53"></a>&nbsp;&nbsp;<span class="src-sym">-&gt;</span><a href="http://www.php.net/next">next</a><span class="src-sym">(</span><span class="src-sym">)</span></div></li>
<li><div class="src-line"><a name="a54"></a>&nbsp;&nbsp;<span class="src-comm">//&nbsp;Add&nbsp;some&nbsp;data&nbsp;to&nbsp;this&nbsp;row</span></div></li>
<li><div class="src-line"><a name="a55"></a>&nbsp;&nbsp;<span class="src-sym">-&gt;</span><span class="src-id">append</span><span class="src-sym">(</span><span class="src-str">'&lt;td&gt;This&nbsp;is&nbsp;the&nbsp;data&lt;/td&gt;'</span><span class="src-sym">)</span></div></li>
<li><div class="src-line"><a name="a56"></a>&nbsp;&nbsp;<span class="src-comm">//&nbsp;Write&nbsp;it&nbsp;all&nbsp;out&nbsp;as&nbsp;HTML</span></div></li>
<li><div class="src-line"><a name="a57"></a>&nbsp;&nbsp;<span class="src-sym">-&gt;</span><span class="src-id">writeHTML</span><span class="src-sym">(</span><span class="src-sym">)</span><span class="src-sym">;</span></div></li>
<li><div class="src-line"><a name="a58"></a><span class="src-php">?&gt;</span></div></li>
</ol>
</span></div>
        <div class="credit">
		    <hr class="separator" />
		    Documentation generated on Thu, 19 Mar 2009 18:01:09 -0500 by <a href="http://www.phpdoc.org">phpDocumentor 1.4.2</a>
	      </div>
      </td></tr></table>
    </td>
  </tr>
</table>

</body>
</html>